home *** CD-ROM | disk | FTP | other *** search
/ Deutsche Edition 1 / Deutsche Edition 1.iso / time / time_61-70 / time_68 / mfr_2.0 / goodies / tasklist.c < prev    next >
C/C++ Source or Header  |  1993-11-04  |  729b  |  35 lines

  1. /* Quick and dirty hack to display all task names */
  2.  
  3. #include "exec/types.h"
  4. #include "exec/execbase.h"
  5. #include "exec/tasks.h"
  6.  
  7. #define MAXTASKS 200
  8. char names[MAXTASKS][50];
  9. extern struct ExecBase *SysBase;
  10.  
  11. int cmp(char *a,char *b) { return(stricmp(a,b)); }
  12.  
  13. main()
  14. {
  15.     LONG nr=0,i;
  16.     struct Task *task;
  17.  
  18.     Forbid();
  19.  
  20.     for (task =(struct Task *)(((struct ExecBase *)SysBase)->TaskWait.lh_Head);
  21.          task!=(struct Task *)(((struct ExecBase *)SysBase)->TaskWait.lh_TailPred->ln_Succ);
  22.          task =(struct Task *)task->tc_Node.ln_Succ)
  23.     {
  24.         if (task->tc_Node.ln_Name) stccpy(names[nr++],task->tc_Node.ln_Name,50);
  25.         if (nr==MAXTASKS) break;
  26.     }
  27.  
  28.     Permit();
  29.  
  30.     qsort(names,nr,50,cmp);
  31.  
  32.     for (i=0;i<nr;i++)
  33.         printf("%s\n",names[i]);
  34. }
  35.